<!-- eslint-disable prettier/prettier -->
<template>
  <div class="main-management">
    <div class="management">
      <div class="manage-header">
        <div class="manage-left">
          <div class="manage-title">值班记录管理</div>
        </div>
      </div>
      <div class="manage-content" v-if="rotaList.length > 0">
        <div class="content-item" v-for="(item, index) of rotaList" :key="index" @click="onSearch(item)">
          <div class="item-left">
            <svg-icon icon-class="location" class="icon-record" />
          </div>
          <div class="item-right">
            <div class="item-title">{{ item.rotaName }}</div>
            <div class="item-date">{{ item.rotaBegin + ' - ' + item.rotaEnd }}</div>
            <div class="item-button">
              <span @click="onSearch(item)">查看</span>
            </div>
          </div>
        </div>
      </div>
  
      <div class="manage-footer" v-if="rotaList.length > 0">
        <span>共{{ rec.pager.total }}条数据</span>
        <a-pagination
          v-model:current="rec.pager.pageNum"
          v-model:pageSize="rec.pager.pageSize"
          show-size-changer
          show-quick-jumper
          :total="rec.pager.total"
          @change="onChange"
          @showSizeChange="onShowSizeChange"
          :pageSizeOptions="['10', '20', '40', '100']"
        />
      </div>
      <a-empty v-if="rotaList.length == 0"/>
    </div>
    
  </div>
  
</template>
<!-- eslint-disable prettier/prettier -->
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { getRotaList } from "@/service/modules/rota/rota";
import router from "@/router";

const rotaList = ref<any>([]);
const rec = ref<any>({
  pager: {
    pageNum: 1,
    pageSize: 10,
    total: 3000,
  },
});

onMounted(() => {
  getList();
});

const getList = () => {
  getRotaList({
    pageNum: rec.value.pager.pageNum,
    pageSize: rec.value.pager.pageSize,
  }).then((res: any) => {
    rotaList.value = res.rows;
    rec.value.pager.total = res.total;
  });
};

const onShowSizeChange = (pageNum: number, pageSize: number) => {
  rec.value.pager.pageNum = pageNum;
  rec.value.pager.pageSize = pageSize;
  getList();
};

const onChange = (pageNum: number) => {
  rec.value.pager.pageNum = pageNum;
  getList();
};

const onSearch = (item) => {
  router.push({
    path: "/rota/recordInfo",
    query: {
      i: item.id,
      rotaBegin: item.rotaBegin, 
      rotaEnd: item.rotaEnd
    },
  });
};
</script>
<style scoped lang="less">
.item-right {
  width: 80%;
}
.main-management {
  width: 100%;
  height: 100%;
}
.management {
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-radius: 10px;
  padding: 0px 24px;
  position: relative;
}
.manage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.manage-left {
  display: flex;
  align-items: center;
}
.manage-button {
  display: flex;
  align-items: center;
}

.manage-title {
  width: 80px;
  height: 64px;
  font-size: 16px;
  font-family: Microsoft YaHei UI, Microsoft YaHei UI-600;
  font-weight: 600;
  text-align: left;
  color: #303233;
  line-height: 64px;
  margin-right: 26.17px;
  white-space: pre;
}

.icon-excla {
  font-size: 11.68px;
  margin-right: 5px;
}

.manage-tip {
  width: 206px;
  height: 18px;
  font-size: 14px;
  font-family: Microsoft YaHei UI, Microsoft YaHei UI-400;
  font-weight: 400;
  text-align: LEFT;
  color: #aaaeb2;
  line-height: 16px;
  letter-spacing: 0.07px;
  white-space: pre;
  display: flex;
  align-items: center;
}

.manage-content {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  max-height: 80%;
  overflow-y: auto;
}
.content-item {
  width: 31%;
  height: 124px;
  border: 1px solid #ebecf4;
  border-radius: 10px;
  margin-right: 16px;
  margin-bottom: 16px;
  padding: 26px 20px;
  display: flex;
  cursor: pointer;
  &:hover {
    width: 31%;
    height: 124px;
    background: #ffffff;
    border: 1px solid #3e77fa;
    border-radius: 10px;
    box-shadow: 0px 6px 10px 0px rgba(13, 61, 172, 0.06);
  }
}

.icon-record {
  width: 36px;
  height: 36px;
  margin-right: 15px;
}

.item-title {
  width: 80%;
  height: 26px;
  font-size: 16px;
  font-family: Microsoft YaHei UI, Microsoft YaHei UI-600;
  font-weight: 600;
  text-align: LEFT;
  color: #303233;
  line-height: 26px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.item-date {
  width: 193px;
  height: 18px;
  font-size: 14px;
  font-family: Arial, Arial-400;
  font-weight: 400;
  text-align: left;
  color: #aaaeb2;
  line-height: 16px;
  margin-top: 4px;
}
.item-button {
  margin-top: 16px;
  height: 20px;
  font-size: 14px;
  font-family: Microsoft YaHei UI, Microsoft YaHei UI-400;
  font-weight: 400;
  text-align: LEFT;
  color: #3e77fa;
  line-height: 20px;
  letter-spacing: 0.07px;
  display: flex;
  span {
    width: 73px;
    height: 20px;
    margin-right: 16px;
    cursor: pointer;
  }
}
.manage-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 95%;
  height: 6%;
  position: absolute;
  bottom: 0px;
  padding-bottom: 20px;
}
</style>
